﻿<script language="javascript">	
	var null_name = 'Mời bạn nhập họ tên';
	var null_que = 'Mời bạn chọn quê quán';
	var null_so = 'Mời bạn nhập số nhà';
	var null_ap = 'Mời bạn nhập ấp/đường';
	var null_xa = 'Mời bạn nhập xã/phường';
	var null_huyen = 'Mời bạn nhập huyện/quận';
	var null_tinh = 'Mời bạn nhập tỉnh/thành phố';
	var null_dt = 'Mời bạn nhập số điện thoại';
	var null_email = 'Mời bạn nhập địa chỉ e-mail';
	var null_lydo = 'Xin bạn cho biết lý do học';
	var null_doitg = 'Mời bạn chọn đối tượng';
	var null_ntt = 'Mời bạn chọn nguồn thông tin';
	var null_lich = 'Mời bạn chọn  lịch học';
	var invalide_dt = 'Số điện thoại từ 8 đến 11 số';
	var invalide_email = 'Địa chỉ e-mail không đúng, xin mời bạn nhập lại';
	
	function validateForm( frm )
	{
		var RE_EMAIL = /^(\w+[\-\.])*\w+@(\w+\.)+[A-Za-z]+$/;

		if ( frm.txtTenKH.value == '')
		{
			alert (null_name);
			frm.txtTenKH.focus();
			return false;
		}
		if ( frm.txtQueQuan.value == '')
		{
			alert (null_que);
			frm.txtQueQuan.focus();
			return false;
		}
		if ( frm.txtSo.value == '')
		{
			alert (null_so);
			frm.txtSo.focus();
			return false;
		}
		if ( frm.txtAp.value == '')
		{
			alert (null_ap);
			frm.txtAp.focus();
			return false;
		}
		if ( frm.txtXa.value == '')
		{
			alert (null_xa);
			frm.txtXa.focus();
			return false;
		}
		if ( frm.txtHuyen.value == '')
		{
			alert (null_huyen);
			frm.txtHuyen.focus();
			return false;
		}
		if ( frm.txtTinh.value == '')
		{
			alert (null_tinh);
			frm.txtTinh.focus();
			return false;
		}
		if ( frm.txtDienThoai.value == '')
		{
			alert (null_dt);
			frm.txtDienThoai.focus();
			return false;
		}
		if ( frm.txtDienThoai.value.length < 8 || frm.txtDienThoai.value.length > 11)
		{
			alert (invalide_dt);
			frm.txtDienThoai.focus();
			return false;
		}
		if ( frm.txtEmail.value == '')
    	{
     		alert (null_email);
			frm.txtEmail.focus();
			return false;
		}
		if ( !RE_EMAIL.test(frm.txtEmail.value) )
		{
			alert (invalide_email);
			frm.txtEmail.select();
			return false;
		}
		if ( frm.txtLyDo.value == '')
    	{
     		alert (null_lydo);
			frm.txtLyDo.focus();
			return false;
		}
		if ( frm.txtDoiTg.value == '')
    	{
     		alert (null_doitg);
			frm.txtDoiTg.focus();
			return false;
		}
		if ( frm.txtNTT.value == '')
    	{
     		alert (null_ntt);
			frm.txtNTT.focus();
			return false;
		}
		if ( frm.txtLich.value == '')
    	{
     		alert (null_lich);
			frm.txtLich.focus();
			return false;
		}
	}
</script>
<style>
.style5k { font-size:16px; color:#000000;}
.style9k {
	color: #FF3399;
	font-weight: bold;
	font-size:14px;
}
.mau{
	color: #930; font-size:12px; font-weight:bold}
</style>
<script type="text/javascript" src="scripts/common.js"></script>
<script type="text/javascript" src="scripts/viettyping.js"></script>

<?php
if(isset($_POST["txtTenKH"])){
		
$nam=$_POST['nam'];
$thang=$_POST['thang'];
$ngay=$_POST['ngay'];				
$ngaysinh = $nam."-".$thang."-".$ngay;
$diachi=$_POST['txtSo'].", ".$_POST['txtAp'].", ".$_POST['txtXa'].", ".$_POST['txtHuyen'].", ".$_POST['txtTinh'];
        $sql = "INSERT INTO `".$dulieu."`.`hocsinh` (`hinhanh`,`hienthi`) VALUES ('".$_FILES["s1"]["name"]."',0);";
	$insert = mysql_query($sql);
        echo"<script language=javascript>window.location='dangky.html';</script>";

}
	?>
<div class="main">

	<h5>ĐĂNG KÝ TRỰC TUYẾN<HR ></h5>

<form name="frm_register" method="post" action="" enctype="multipart/form-data" onsubmit="return validateForm(this);" >
<table class="contentpaneopen" style="padding-left:15px; border:1px #CCC solid;">
				<tbody>
                <tr>

<td style="font-style: italic; color: red;" colspan="4" align="center">Nhập đầy đủ các thông tin đăng ký.<br>Bạn có thể gõ tiếng Việt trực tiếp, không cần chương trình gõ tiếng Việt.<br>&nbsp;</td>                                                            
</tr>
                                                                            <tr>
                                                                <td colspan="4">&nbsp;</td>
                                                            </tr>

                                                            <tr>
                                                                <td width="89" valign="top" class="caption1"><strong>Họ tên</strong></td>
                                                                <td width="58" valign="top" class="caption1"><strong>:</strong></td>
                                                                <td colspan="2"><input name="txtTenKH" id="txtTenKH" class="textbox" tabindex="1" style="width:200px" maxlength="200" value="<?php echo $_POST['txtTenKH'] ?>"></td>
                                                            </tr>
                                                            <tr>
                                                                <td width="89" valign="top" class="caption1" ><strong>Giới tính</strong></td>
                                                               <td width="58" valign="top" class="caption1"><strong>:</strong></td>
                                                                <td width="86" >
                                                                    <input tabindex="2" value="1" name="chkGT" type="radio" <?php if($_POST['chkGT'] == 1 || $_POST['chkGT'] == ''){ echo "checked=checked"; } ?>>Nam
                                                                </td>
                                                                <td width="348" >
                                                                    <input tabindex="3" value="0" name="chkGT" type="radio" <?php if($_POST['chkGT'] == 0 || $_POST['chkGT'] != ''){ echo "checked=checked"; } ?>>Nữ</td>
                                                            </tr>
                                                                                                                        <tr>
                                                                <td class="caption1" valign="top"><strong>Ngày Sinh</strong></td>
                                                                <td width="58" valign="top" class="caption1"><strong>:</strong></td>
                                                               <td colspan="2" valign="top">
<select name="ngay" tabindex="4">
	<option value="01" selected="selected">1</option>
	<option value="02">2</option>
	<option value="03">3</option>
	<option value="04">4</option>
	<option value="05">5</option>
	<option value="06">6</option>
	<option value="07">7</option>
	<option value="08">8</option>
	<option value="09">9</option>
	<option value="10">10</option>
	<option value="11">11</option>
	<option value="12">12</option>
	<option value="13">13</option>
	<option value="14">14</option>
	<option value="15">15</option>
	<option value="16">16</option>
	<option value="17">17</option>
	<option value="18">18</option>
	<option value="19">19</option>
	<option value="20">20</option>
	<option value="21">21</option>
	<option value="22">22</option>
	<option value="23">23</option>
	<option value="24">24</option>
	<option value="25">25</option>
	<option value="26">26</option>
	<option value="27">27</option>
	<option value="28">28</option>
	<option value="29">29</option>
	<option value="30">30</option>
	<option value="31">31</option>
</select>

<select name="thang" tabindex="5">
	<option value="01" <?php if(date('m')=='01') echo "selected='selected'" ?>> 01 
	</option><option value="02" <?php if(date('m')=='02') echo "selected='selected'" ?>> 02 
	</option><option value="03" <?php if(date('m')=='03') echo "selected='selected'" ?>> 03 
	</option><option value="04" <?php if(date('m')=='04') echo "selected='selected'" ?>> 04 
	</option><option value="05" <?php if(date('m')=='05') echo "selected='selected'" ?>> 05 
	</option><option value="06" <?php if(date('m')=='06') echo "selected='selected'" ?>> 06 
	</option><option value="07" <?php if(date('m')=='07') echo "selected='selected'" ?>> 07 
	</option><option value="08" <?php if(date('m')=='08') echo "selected='selected'" ?>> 08 
	</option><option value="09" <?php if(date('m')=='09') echo "selected='selected'" ?>> 09 
	</option><option value="10" <?php if(date('m')=='10') echo "selected='selected'" ?>> 10 
	</option><option value="11" <?php if(date('m')=='11') echo "selected='selected'" ?>> 11 
	</option><option value="12" <?php if(date('m')=='12') echo "selected='selected'" ?>> 11 
</option></select>

<select name="nam" tabindex="6">
<?php
$n=date('y')+2000;
for($i=1940;$i<=$n;$i++){
?>
<option value="<?php echo $i ?>" <?php if($i==$n) echo "selected='selected'" ?>><?php echo $i ?></option>
<?php
}
?>
</select>
</td>
                                                            </tr>
                                                            <tr>
                                                                <td width="89" valign="top" class="caption1" ><strong>Nơi sinh</strong></td>
                                                               <td width="58" valign="top" class="caption1"><strong>:</strong></td>
                                                                <td colspan="2">
                                                                <input name="noisinh" id="noisinh" class="textbox" tabindex="1" style="width:200px" maxlength="200" value="<?php echo $_POST['noisinh'] ?>" />
                                                                </td>
                                                            </tr>
                                                                                                                        <tr>
                                                                <td width="89" valign="top" class="caption1" ><strong>CMND</strong></td>
                                                               <td width="58" valign="top" class="caption1"><strong>:</strong></td>
                                                                <td colspan="2"><input name="CMND" id="CMND" class="textbox" tabindex="1" style="width:200px" maxlength="200" value="<?php echo $_POST['CMND'] ?>" /></td>
                                                            </tr>
                                                            <tr>
                                                                <td  class="caption1" colspan="2" valign="top"><strong>Địa chỉ liên hệ</strong></td>
                                                                <td colspan="2">&nbsp;</td>
                                                            </tr>
                                                            <tr>
                                                                <td  class="caption1" valign="top" colspan="2">&nbsp;&nbsp;&nbsp;Số nhà &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp;:</td>
                                                                <td colspan="2"><input id="txtSo" name="txtSo" style="width:200px" class="textbox" tabindex="8"  value="<?php echo $_POST['txtSo'] ?>"></td>
                                                            </tr>
                                                             <tr>
                                                                <td  class="caption1" valign="top" colspan="2">&nbsp;&nbsp;&nbsp;Ấp/Đường &nbsp;&nbsp; &nbsp;:</td>
                                                                <td colspan="2"><input id="txtAp" name="txtAp" style="width:200px" tabindex="9" class="textbox" value="<?php echo $_POST['txtAp'] ?>"></td>
                                                            </tr>
                                                             <tr>
                                                                <td  class="caption1" colspan="2" valign="top">&nbsp;&nbsp;&nbsp;Xã/Phường &nbsp; &nbsp;:</td>
                                                                <td colspan="2"><input id="txtXa" name="txtXa" tabindex="10" style="width:200px" class="textbox" value="<?php echo $_POST['txtXa'] ?>"></td>
                                                            </tr>
                                                             <tr>
                                                                <td  class="caption1" valign="top" colspan="2">&nbsp;&nbsp;&nbsp;Huyện/Quận &nbsp;:</td>
                                                                <td colspan="2"><input id="txtHuyen" name="txtHuyen" class="textbox" style="width:200px" tabindex="11" value="<?php echo $_POST['txtHuyen'] ?>"></td>
                                                            </tr>
                                                             <tr>
                                                                <td  class="caption1" valign="top" colspan="2">&nbsp;&nbsp;&nbsp;Tỉnh/TP &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;:</td>
                                                                <td colspan="2">
                                                                <input id="txtTinh" name="txtTinh" class="textbox" style="width:200px" tabindex="11" value="<?php echo $_POST['txtTinh'] ?>">
                                                                </td>
                                                            </tr>

                                                            <tr>
                                                                <td  class="caption1" valign="top"><strong>Email</strong></td>
                                                                <td width="58" valign="top" class="caption1"><strong>:</strong></td>
                                                                <td colspan="2" valign="top"><input id="txtEmail" name="txtEmail" style="width:200px" class="textbox" tabindex="13" maxlength="300" onKeyPress="return inputEmail(event);" value="" /> </td>
                                                            </tr>                                                            
                                                            <tr>
                                                                <td valign="top" class="caption1"  colspan="2"><strong>Đăng ký lớp học :</strong></td>
                                                                <td colspan="2"><select name="txtLich" id="txtLich"  tabindex="14" style="width:300px; color:#000"  multiple="multiple">
                                                             <?php 
				$query2 = "select * from  `".$dulieu."`.`coso`";
				$kq2 = mysql_query($query2);
				while($row2 = mysql_fetch_array($kq2))
				{?>
				<option value="<?php echo $row2['L_STT'] ?>"><?php echo $row2['TenCS'] ?></option>
				<?php
				}
				?>	
                                                                </select></td>
                                                            </tr> 
                                                            
                                                            <tr>
                                                             <td height="45" align="left" colspan="4" style="padding-left:150px">
                                                             <input name="sumit" class="button_1" type="submit" value=" Đăng ký " />
                                                             <input name="huy" class="button_1" type="reset" value="     Hủy     " /></td>
                                                            </tr>
                                                              <tr>
                                                                <td style="font-style: italic; color: red;" colspan="4" align="center">&nbsp;</td>
                                                            </tr>
				</tbody></table>
</form> </div>